package com.capt_4.equation;

public class SubEquation extends Equation {
    @Override
    public int calculate() {
        return getLeftNumber()-getRightNumber();
    }

    public SubEquation() {
    }

    public SubEquation(String equationString){
        int i1 = equationString.indexOf("-");
        int i2 = equationString.indexOf("=");
//        String left = equationString.substring(0, i1);
        String left = equationString.substring(0, i1);
        String right = equationString.substring(i1+1, i2);

        int leftNumber = Integer.parseInt(left);
        int rightNumber = Integer.parseInt(right);

        setLeftNumber(leftNumber);
        setRightNumber(rightNumber);
        setOp('-');
        setResult(leftNumber-rightNumber);
    }
}
